package com.after.saas.file.constants;

import com.after.saas.file.function.DefaultConsumer;
import com.after.saas.file.function.DictConsumer;
import com.after.saas.file.function.UserConsumer;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @Classname ModuleEnum
 * @Description TODO
 * @Date 2021/3/25 9:44
 * @Created by hjchen
 */

@Getter
public enum ModuleEnum {

    DEFAULT_MODULE("DEFAULT_IMPORT", "", DefaultConsumer.class),
    USER_MODULE("USER_IMPORT", "02-用户-导入模板.xlsx", UserConsumer.class),
    DICT_MODULE("DICT_IMPORT", "03-字典-导入模板.xlsx", DictConsumer.class),

    ;

    String moduleCode;
    String moduleFile;
    Class<?> clazz;

    ModuleEnum(String moduleCode, String moduleFile, Class<?> clazz) {
        this.moduleCode = moduleCode;
        this.moduleFile = moduleFile;
        this.clazz = clazz;
    }

    public static ModuleEnum getClazzByCode(String moduleCode) {
        for (ModuleEnum moduleEnum : values()) {
            if (StringUtils.equals(moduleCode, moduleEnum.getModuleCode())) {
                return moduleEnum;
            }
        }
        return DEFAULT_MODULE;
    }

}